package GUI;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import java.awt.Font;
import javax.swing.JComboBox;
import javax.swing.JButton;

import Controller.Client;
import Entity.ParkingLot;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

/**
 * this is the GUI for the information station choosing the parking lot.
 * @author Or Marx
 */
public class FrameIS extends JFrame{
	private static int parkingLotNum;
	public static int getParkingLot()
	{
		return parkingLotNum;
	}
	static JFrame frame;
	public static JFrame getFrame()
	{
		return frame;
	}
	/**
	 * is the constructor. it has combo box for choosing the parking lot.
	 */
	public FrameIS() {
		getContentPane().setLayout(null);
		
		JLabel lblChooseParkingLot = new JLabel("Choose Parking lot");
		lblChooseParkingLot.setFont(new Font("Tahoma", Font.PLAIN, 17));
		lblChooseParkingLot.setBounds(339, 40, 219, 41);
		getContentPane().add(lblChooseParkingLot);
		
		final JComboBox comboBox = new JComboBox();
		comboBox.setBounds(339, 112, 136, 20);
		getContentPane().add(comboBox);
		
		JButton btnChoose = new JButton("choose");
		btnChoose.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				parkingLotNum=comboBox.getSelectedIndex()+1;
				JFrame frame=FrameIS.getFrame();
				ISMainGui isGui=new ISMainGui();
				isGui.setLastPanel((JPanel)frame.getContentPane());
				isGui.setFrame(frame);
				frame.setContentPane(isGui);
				frame.setVisible(true);
				
			}
		});
		btnChoose.setBounds(360, 304, 89, 23);
		getContentPane().add(btnChoose);
		
		ParkingLot[] plots=Client.getParkingLots_sorted();
		for (int i=0; i<plots.length;i++)
			comboBox.addItem(plots[i].getParking_lot_name());
		frame=this;
	}
}
